Using standard C library routines is also prone to errors arising from invalid assumptions. The malloc memory allocation routine is a good example. While a bad practice, the value passed to malloc's allocation size parameter may be based on implicit type size assumptions. For example:
#include <stdlib.h> long *list20; list20 = (long*) malloc(20*4);instead of:
list20 = (long*) malloc(20 * sizeof(long));Compilers are unlikely to report such problems. You can find these hard-to-find problems by inspection of the code and the use of a debugging malloc package during testing. Other routines requiring byte extent lengths like bcopy, bzero, memset, memcpy, and memmove are subject to the same problem.